package com.mt.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author Wang
 * @Description 角色枚举
 * @date 2020/11/15-19:20
 */
@Getter
public enum RoleType {
    SYS_ADMIN(0,"SYS_ADMIN"),
    NORMAL_ADMIN(1,"NORMAL_ADMIN"),
    SELLER(2,"SELLER"),
    NORMAL_CUSTOMER(3,"NORMAL_CUSTOMER"),
    VIP_CUSTOMER(4,"VIP_CUSTOMER");

    @EnumValue
    private Integer  code;
    @JsonValue
    private String  type;


    RoleType(Integer code,String type) {
        this.code = code;
        this.type = type;
    }

    public static  int TypeCode(RoleType listType) {
        for (RoleType type :RoleType.values()){
            if (type.getType()==listType.getType()) {
                return type.getCode();
            }
        }
        return -1;
    }

    public static  String TypeName(RoleType listType) {
        for (RoleType type :RoleType.values()){
            if (type.getCode().equals(listType.getCode())) {
                return type.getType();
            }
        }
        return null;
    }

}
